package com.bite;

import java.util.Arrays;

public class Test {
    public static void main(String[] args) {
        //不规则数组,后面可以逐次对array中的数组进行赋值
        //每一行可以不同列
        int[][] array = new int[2][];
        array[0] = new int[3];
        array[1] = new int[5];
        for (int[] tmp:array) {
            for (int x:tmp) {
                System.out.print(x + " ");
            }
            System.out.println();
        }

    }
    public static void main1(String[] args) {
        //二维数组的定义
        int[][] array1 = {{1,2,3},{4,5,6}};
        int[][] array2 = new int[][]{{1,2,3},{4,5,6}};
        int[][] array3 = new int[2][3];//初始化为0
        int[][] array4 = new int[2][];//不规则初始化
//        int[][] array5 = new int[][4];//java当中要确定行,不可以只确定列

        //二维数组的遍历
        for (int i = 0; i < array1.length; i++) {
            for (int j = 0; j < array1[i].length; j++) {
                System.out.print(array1[i][j] + " ");
            }
            System.out.println();
        }
        System.out.println("=======");
        //注意: foreach 里面假如要遍历二维数组的话,二维数组是由几个一维数组构成的
        for (int[] tmp : array1) {
            for(int x : tmp) {
                System.out.print(x + " ");
            }
            System.out.println();
        }
        System.out.println("=======");
        //二维数组存的是一维数组,一位数组是一个对象,返回[I@4dd8dc3]
//        System.out.println(Arrays.toString(array1));
        System.out.println(Arrays.deepToString(array1));

    }
}
